package com.central.apps.handler.project;

import com.central.app.common.base.BaseHandler;
import com.central.app.service.HandlerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 处理项目风险业务逻辑
 *
 * @author lidachao
 * @date 2023/5/19
 */
@Component
@Slf4j
public class ProjectRiskHandler extends BaseHandler {

    @Autowired
    private HandlerService handlerService;

    @Override
    public Object operate(String app, String type, Map<String, Object> params) throws Exception {
        if ("setActive".equals(type)) {
            Integer id = MapUtils.getInteger(params, "id");
            // 更新风险状态
            handlerService.updateBySql("update gq_prorisk set status = '激活' where id = " + id);
        }
        if ("setClose".equals(type)) {
            Integer id = MapUtils.getInteger(params, "id");
            // 更新风险状态
            handlerService.updateBySql("update gq_prorisk set status = '关闭' where id = " + id);
        }
        return null;
    }
}
